<template>
  <div>
  <div class="app-container">

      <el-form :inline="true" class="demo-form-inline">
        <el-form-item label="企业名称">
          <el-input v-model="searchObj.licence18" placeholder="企业名称"/>

        </el-form-item>
        <el-form-item label="统一社会信用代码">
          <el-input v-model="searchObj.licence13" placeholder="统一社会信用代码"/>
        </el-form-item>
        <el-button type="primary" icon="el-icon-search" @click="getList()">查询</el-button>
      </el-form>

    <el-table :data="list" stripe style="width: 100%">
      <el-table-column prop="licence18" label="企业名称" :min-width="120"/>
      <el-table-column prop="licence13" label="统一社会信用代码" :min-width="80" />
      <el-table-column prop="bizType" label="业务类型" :min-width="60" />
      <el-table-column prop="username" label="用户名" :min-width="60" />
      <el-table-column prop="logDate" label="时间" :min-width="80"  :formatter="formatLogDate"/>
    </el-table>
    <!-- 分页 -->
    <el-pagination
      :current-page="current"
      :page-size="limit"
      :total="total"
      style="padding: 30px 0; text-align: center;"
      layout="total, prev, pager, next, jumper"
      @current-change="getList"
    />
  </div>
  </div>
</template>
<script>
  import businessApi from "@/api/business/query";
  import {myLogout} from "@/api/login";
  export default {
    data() {
      return {
        // 定义变量  数据
        current: 1,
        limit: 10,
        list: [],
        total: 0,
        searchObj: {},
      }
    },
    created() {
      this.getList()
    },
    methods: {
      // 业务查询列表
      getList(current = 1) {
        this.current = current
        businessApi.getList(this.current, this.limit, this.searchObj)
          .then(response => {
            this.list = response.data.records
            this.total = response.data.total
          })
          .catch(error => {
            console.log(error)
            myLogout();
            this.$store.dispatch('LogOut').then(() => {
              location.reload() // 为了重新实例化vue-router对象 避免bug
            })
          });
      },
      formatLogDate(row, column, cellValue) {
        // 取前 19 个字符（年月日时分秒部分）
        return cellValue.slice(0, 19);
      }
    }
  }
</script>
